package cn.tedu.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class User {
    /**
     * @Value注解 可以给标记的属性直接赋值
     * 通常会和配置文件一起使用,辅助将配置文件的属性值注入到对应的属性中,
     * 仅需要通过${属性名}的方式即可注入
     */
    @Value("${user.username}")
    private String name;
    @Value("${user.age}")
    private int age;

    public User() {
    }

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "我叫 " + name + ",今年 " + age + " 岁!";
    }
}
